package cn.tedu.baidashi.controller;

import cn.tedu.baidashi.model.User;
import cn.tedu.baidashi.service.IUserService;
import cn.tedu.baidashi.service.Impl.UserServiceImpl;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YYL
 * @since 2022-02-19
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService userService;

    @GetMapping("/currentUser")
    public User getCurrentUser(@AuthenticationPrincipal UserDetails user){
        User getUser = userService.getUser(user.getUsername());
        return getUser;
    }

}
